Adding a Button-Toggle to a ControlBar

Description

You can add a Button-Toggle to a ControlBar. Toggle buttons can either be two-state (switching between a true and a false state), or multi-state (each click advances to the next button state). The video shows how the state of a Button-Toggle is used to control what action a button performs when clicked.

images/tog45.png
A toggle button in the top right determines the direction to move through a list control.

For a visual explanation on how the state of a Button-Toggle is used to control what action a button performs when clicked follow the guide below or watch this video:

Adding a Button-Toggle to a ControlBar

In this video we show how you can add a Button-Toggle to a ControlBar. Toggle buttons can either be two-state (switching between a true and a false state), or multi-state (each click advances to the next button state).

The video shows how the state of a Button-Toggle is used to control what action a button performs when clicked.

Download Component

2016-09-14

Create a Component with a ControlBar and List

  1. In the UX Builder open the Properties page. In the UX Properties section click the button next to the 'Style name' property.

    images/tog.png
  2. From the 'Location' menu select 'System' and from the style options select the 'Alpha' style. Click OK.

    images/tog2.png
  3. Open the UX Controls page and check the 'Mobile' checkbox.

    images/tog3.png
  4. Open the Panels menu and select the [Panel Card] option to add a panel card to the component tree.

    images/tog4.png
  5. Highlight the panel card. Open the 'Containers' menu and click on the [Container] option.

    images/tog5.png
  6. From the Container Type list select 'PanelHeader' and click the 'Insert After' button.

    images/tog6.png
  7. Highlight the panel header. Open the 'Other Controls' menu and select the [ControlBar] option to add a control-bar to the panel header.

    images/tog7.png
  8. Highlight [PanelHeader End: PANELHEADER_1]. Open the Data Controls menu and click [List] to add a list control underneath the panel header.

    images/tog8.png
  9. Highlight the list control. In the properties list on the right, under List Properties, click the button next to the 'List properties' property to open the List Builder.

    images/tog9.png
  10. In the List Builder open the Data Source Pane. Set the 'Data Source Type' to SQL.

    images/tog10.png
  11. Click on the button next to the Connection String property, in the SQL Data Source section.

    images/tog11.png
  12. Set the 'Table name' property to the 'Customers table.

    images/tog12.png
  13. Click the button next to the 'Field list' property and select the 'ContactName' and 'City fields'.

    images/tog13.png
  14. Open the List Layout pane. Use the blue > arrow to move the ContactName and City fields from the Available Fields list to the 'Columns in List' area. Click OK to close the list builder.

    images/tog14.png
  15. The component tree should now look like this:

    images/tog15.png

Add a Button-Toggle that Navigates the List

  1. Highlight [ControlBar:CONTROLBAR_1]. In the Properties list under ControlBar Properties click the 'ControlBar properties' property to open the ControlBar Builder.

    images/tog16.png
  2. In the ControlBar Builder open the 'Items' pane and click the 'Add ControlBar Item' button.

    images/tog17.png
  3. Select 'button-toggle' option from the Item Type choices and click OK.

    images/tog18.png
  4. In the ControlBar Item Properties menu go to the 'Button Settings for Button-Toggle' section. Set the 'Button layout' property to 'Image only'.

    images/tog19.png
  5. In the same section click the button next to the 'Icon' property.

    images/tog20.png
  6. In the 'Specify Image' dialog select 'SVG Icon' from the list of radio button choices. Hit the 'Select' button.

    images/tog21.png
  7. Click on the 'arrowDown' SVG icon to select it and click OK and OK again.

    images/tog22.png
  8. Back in the 'Items' pane click the button next to the 'Pressed icon' property. This should be just below to Icon property.

    images/tog23.png
  9. Choose the SVG Icon property and click 'Select'.

    images/tog24.png
  10. Click on the 'arrowUp' icon and click OK and OK again.

    images/tog25.png
  11. In the 'Items' pane scroll up the ControlBar Item Properties list to the 'Button-Toggle Settings'. Make sure the Type property is set to 'Two-State'.

    images/tog26.png
  12. Next to the 'Data variable' property define a new data variable called 'toggleState'.

    images/tog27.png
  13. Open the 'Actions' pane and click on the 'Add Action' button to create a new action. Give the action the name 'next'.

    images/tog28.png
  14. Add the following Javascript to define the action:

    var lObj = {dialog.object}.getControl('list1');
    if(!this.data.toggleState) {
        lObj.navigate('next');
    } else {
        lObj.navigate('prev');
    }
    images/tog29.png
  15. Open the 'Items' pane again. Click the 'Add ControlBar Item' button.

    images/tog30.png
  16. From the Item Type choices select 'button' and click OK.

    images/tog31.png
  17. Highlight the button item. In the ControlBar Item Properties list, under 'Item Actions', hit the button next to the 'Click' property.

    images/tog32.png
  18. Select the 'next' action that you just defined.

    images/tog33.png
  19. Scroll down the ControlBar Item Properties list to the Button Settings. Change the 'Button layout' property to be 'Image followed by text'.

    images/tog34.png
  20. Click the button next to the Icon property.

    images/tog35.png
  21. In the Specify Image dialog select the 'SVG Icon' option and click 'Select'.

    images/tog36.png
  22. Select the 'arrowsVertical' icon and click OK and OK again.

    images/tog37.png
  23. Towards the bottom of the Button Settings section set the 'Button text' property to read 'Move'.

    images/tog38.png
  24. Open the ControlBar Layout pane. Click the 'Add Layout' button. Give the layout a name like Layout1 and click OK.

    images/tog39.png
  25. Click the 'Add Line' button

    images/tog40.png
  26. Click the 'Add' button under the Before section, highlight the button item you defined, and click OK.

    images/tog41.png
  27. Add the 'button-toggle' item to the 'After:' section by clicking the 'Add' button, highlighting the 'button-toggle' item and clicking OK. Click OK to close the Edit Layout Line dialog.

    images/tog42.png
  28. Click OK again to close the ControlBar Builder. Run the component in Live Preview

    images/tog43.png
  29. Click on a row in the list and press the 'Move' button. You should be able to move down the list control.

    images/tog44.png
  30. Now try pressing the button-toggle button. The icon should change to point up. Click on the Move button again and you should be able to move up through the rows in the list control.

    images/tog45.png